import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToOne,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';
import { IsNotEmpty } from 'class-validator';
import { Dictionary } from './dictionary.entity';

@Entity()
export class DictionaryItem {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  @IsNotEmpty()
  key: string;

  @Column()
  @IsNotEmpty()
  value: string;

  @ManyToOne(() => Dictionary, (dictionary) => dictionary.items)
  dictionary: Dictionary;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;
}
